import { searchFilter } from './common'

export const insertTimeOptions = {
  text: '时间',
  title: '时间',
  name: 'insert_time',
  class: 'txt-center',
  checked: '',
  value: 2,
  options: [
    {
      text: '今日',
      value: 0
    },

    {
      text: '本周',
      value: 1
    },

    {
      text: '本月',
      value: 2
    },

    {
      text: '三个月内',
      value: 3
    },

    {
      text: '不限',
      value: '-1'
    }
  ]
}

export const teamsOptions = {
  text: '公海范围',
  name: 'team_id',
  class: 'txt-center',
  value: 1,
  checked: '',
  options: [
  ]
}

export const orderOptions = {
  title: '排序',
  name: 'order_by',
  class: 'txt-center',
  checked: '',
  options: [
    {
      text: '创建时间倒序',
      value: ''
    },
    {
      text: '录入时间倒序',
      value: 0
    },
    {
      text: '更新时间倒序',
      value: 1
    },

    {
      text:'姓名正序',
      value: 2
    }
  ]
}

export const getTopFilterOptions = (teams) => {
  let teamsOptionList = [
    {
      text: '企业公海',
      value: ''
    }
  ]
  for (const id in teams) {
    const teamName = teams[id]
    const option = {
      text: teamName + '公海',
      value: id
    }
    teamsOptionList.push(option)
  }

  teamsOptions.options = teamsOptionList
  if (teams && Object.keys(teams).length) {
    teamsOptions.checked = teamsOptionList[1].value
  }

  const filterOptions = {
    title: '筛选',
    name: 'filter',
    class: 'txt-center',
    value: 1,
    checked: 1,
    options: [
      teamsOptions,
      insertTimeOptions
    ]
  }

  const topFilterOptions = [
    searchFilter,
    filterOptions,
    orderOptions
  ]

  return topFilterOptions
}

export const topFilterOptions = [
  searchFilter,
  insertTimeOptions,
  orderOptions
]
